#!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''
@Project ：hiflyworks_web_tests 
@File    ：upload_image.py
@Author  ：beibei
@Date    ：2025/6/20 6:59 PM 
'''
import random
import glob
from pathlib import Path

def choose_random_image(relative_dir="test_data/image"):
    """
    从指定目录中随机选取一张 jpeg/jpg/png 图片
    返回绝对路径
    """
    pattern = str(Path(__file__).parent.parent / relative_dir / "*.[jJpP]*[eEgG]*")  # 适配 jpeg/jpg/png
    candidates = glob.glob(pattern)
    if not candidates:
        raise FileNotFoundError(f"No images found in {relative_dir}")
    return Path(random.choice(candidates)).resolve()

